<?php
/**
 * DMFramework
 * 
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @url http://dmframework.nl
 */

/**
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @package System.Library.Database.Table.Iterator
 */
class Dmf_Database_Table_Iterator_Iterator implements Iterator
{
    /**
     * All data
     * 
     * @var array 
     */
    private $_data = array();
    
    /**
     * Constructor
     * 
     * @param array $data 
     */
    public function __construct( $data )
    {
        $this->_data = $data;
    }
    
    /**
     * Implementing the default rewind function 
     */
    public function rewind()
    {
        reset( $this->_data );
    }
    
    /**
     * Implementing the default current function
     * 
     * @return Dmf_Database_Table 
     */
    public function current()
    {
        return current( $this->_data );
    }
    
    /**
     * Implementing the default key function
     * 
     * @return string
     */
    public function key()
    {
        return key( $this->_data );
    }
    
    /**
     * Implementing the default next function
     * 
     * @return Dmf_Database_Table
     */
    public function next()
    {
        return next( $this->_data );
    }
    
    /**
     * Implementing the default valid function
     * 
     * @return Dmf_Database_Table
     */
    public function valid()
    {
        $key = key( $this->_data );
        
        return ( $key !== null && $key !== false );
    }
}